package com.hmall.search.web;


import com.hmall.common.clients.ItemClient;
import com.hmall.common.dto.PageDTO;
import com.hmall.common.pojo.Item;
import com.hmall.common.pojo.RequestParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * hm-mall
 * 2024/11/15 20:21
 * SearchController By 1mZ
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private ItemClient itemClient;  // 注入 Feign 客户端

    @PostMapping("/filters")
    public Map<String, List<String>> getFilterOptions(@RequestBody RequestParams requestParams) {
        // 调用 Feign 客户端方法，获取过滤选项
        Map<String, List<String>> filterOptions = itemClient.getFilterOptions(requestParams);
        return filterOptions;  // 返回过滤选项
    }
    @PostMapping("/list")
    public PageDTO<Item> getList(@RequestBody RequestParams requestParams){
        PageDTO<Item> list = itemClient.getList(requestParams);
        return list;
    }
}
